package BALockRefine;

import java.util.concurrent.locks.Lock;

public class DepositThread implements Runnable {

    private final int amount;
    private final Account account;
    private Lock lock;

    DepositThread(Account x, int amount, Lock lock) {
        account = x;
        this.amount = amount;
        this.lock = lock;
    }

    public void run() {
        lock.lock();
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        account.deposit(amount);
        lock.unlock();
    }
}